<?php
class ObjectControl extends AuthControl{
	private $_db;
	public function __init(){
		parent::__init();
		$this->_db=K('object');
	}
	 public function index(){
		$page = new Page($this->_db->count(),10);
		$this->page =$page->show();
		$this->vote=$this->_db->limit($page->limit())->order('oid desc')->all();
		$this->display();
    }
	public function add(){
		if(IS_POST){
			if($this->_db->add_vote()){
				$this->success('添加成功','index');
			}else{
				$this->error('添加失败',$this->_db->error);
			}
		}else{
			$this->display();
		}
	}
	public function edit(){
		if(IS_POST){
			if($this->_db->edit_vote()){
				$this->success('修改成功','index');
			}else{
    			$this->error('修改失败',$this->_db->error);
    		}
		}else{
			$this->field=$this->_db->find(Q("oid"));
			$this->display();
		}
	}
	public function del(){
		if($this->_db->del_vote()){
			$this->ajax(array('state'=>1,'message'=>'删除成功'));
		}else{
			$this->ajax(array('state'=>0,'message'=>$this->_db->error));
		}
	}
	
}
?>